const mysql=require("mysql")

const pool=mysql.createPool({
   host:'localhost',
   user:'root',
   password:'dgjl418',
   database:'deviation'
})

const sqlConnect=(sql,params)=>{
   return new Promise((resolve,reject)=>{
      pool.getConnection((err,connection)=>{
         if(err){
            reject(err)
         }else{
            connection.query(sql,params,(err,result)=>{
               if(err){
                  reject(err)
               } else {
                  resolve(result)
               }
               connection.release() 
            })
         }
      })
   })
}

module.exports = {
   sqlConnect
}